home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / gnu / bash / bash_108 / bash-108.zoo / bash-1.08 / posixstat.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-05-17  |  4.3 KB  |  141 lines

  1. /* posixstat.h -- Posix stat(2) definitions for systems that
  2.    don't have them. */
  3.  
  4. /* Copyright (C) 1987,1991 Free Software Foundation, Inc.
  5.  
  6.    This file is part of GNU Bash, the Bourne Again SHell.
  7.  
  8.    Bash is free software; you can redistribute it and/or modify it
  9.    under the terms of the GNU General Public License as published by
  10.    the Free Software Foundation; either version 1, or (at your option)
  11.    any later version.
  12.  
  13.    Bash is distributed in the hope that it will be useful, but WITHOUT
  14.    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  15.    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
  16.    License for more details.
  17.  
  18.    You should have received a copy of the GNU General Public License
  19.    along with Bash; see the file COPYING.  If not, write to the Free
  20.    Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
  21.  
  22. /* This file should be included instead of <sys/stat.h>.
  23.    It relies on the local sys/stat.h to work though. */
  24. #ifndef _POSIXSTAT_H
  25. #define _POSIXSTAT_H
  26.  
  27. #include <sys/stat.h>
  28.  
  29. /* This text is taken directly from the Cadmus I was trying to
  30.    compile on:
  31.     the following MACROs are defined for X/OPEN compatibility
  32.     however, is the param correct ??
  33.    #define S_ISBLK(s) ((s.st_mode & S_IFMT) == S_IFBLK)
  34.  
  35.   Well, loser, the answer is no.  Do you still work at Cadmus? */
  36. #if defined (cadmus) && defined (BrainDeath)
  37. #  undef S_ISBLK
  38. #  undef S_ISCHR
  39. #  undef S_ISDIR
  40. #  undef S_ISFIFO
  41. #  undef S_ISREG
  42. #endif /* Horrible-Brain-Death-From-Birth */
  43.  
  44. /* Posix 1003.1 5.6.1.1 <sys/stat.h> file types */
  45.  
  46. /* Some Posix-wannabe systems define _S_IF* macros instead of S_IF*, but
  47.    do not provide the S_IS* macros that Posix requires. */
  48.  
  49. #if defined (_S_IFMT) && !defined (S_IFMT)
  50. #define S_IFMT _S_IFMT
  51. #endif
  52. #if defined (_S_IFIFO) && !defined (S_IFIFO)
  53. #define S_IFIFO _S_IFIFO
  54. #endif
  55. #if defined (_S_IFCHR) && !defined (S_IFCHR)
  56. #define S_IFCHR _S_IFCHR
  57. #endif
  58. #if defined (_S_IFDIR) && !defined (S_IFDIR)
  59. #define S_IFDIR _S_IFDIR
  60. #endif
  61. #if defined (_S_IFBLK) && !defined (S_IFBLK)
  62. #define S_IFBLK _S_IFBLK
  63. #endif
  64. #if defined (_S_IFREG) && !defined (S_IFREG)
  65. #define S_IFREG _S_IFREG
  66. #endif
  67. #if defined (_S_IFLNK) && !defined (S_IFLNK)
  68. #define S_IFLNK _S_IFLNK
  69. #endif
  70. #if defined (_S_IFSOCK) && !defined (S_IFSOCK)
  71. #define S_IFSOCK _S_IFSOCK
  72. #endif
  73.  
  74. /* Test for each symbol individually and define the ones necessary (some
  75.    systems claiming Posix compatibility define some but not all). */
  76.  
  77. #if defined (S_IFBLK) && !defined (S_ISBLK)
  78. #define    S_ISBLK(m)    (((m)&S_IFMT) == S_IFBLK)    /* block device */
  79. #endif
  80.  
  81. #if defined (S_IFCHR) && !defined (S_ISCHR)
  82. #define    S_ISCHR(m)    (((m)&S_IFMT) == S_IFCHR)    /* character device */
  83. #endif
  84.  
  85. #if defined (S_IFDIR) && !defined (S_ISDIR)
  86. #define    S_ISDIR(m)    (((m)&S_IFMT) == S_IFDIR)    /* directory */
  87. #endif
  88.  
  89. #if defined (S_IFREG) && !defined (S_ISREG)
  90. #define    S_ISREG(m)    (((m)&S_IFMT) == S_IFREG)    /* file */
  91. #endif
  92.  
  93. #if defined (S_IFIFO) && !defined (S_ISFIFO)
  94. #define    S_ISFIFO(m)    (((m)&S_IFMT) == S_IFIFO)    /* fifo - named pipe */
  95. #endif
  96.  
  97. #if defined (S_IFLNK) && !defined (S_ISLNK)
  98. #define    S_ISLNK(m)    (((m)&S_IFMT) == S_IFLNK)    /* symbolic link */
  99. #endif
  100.  
  101. #if defined (S_IFSOCK) && !defined (S_ISSOCK)
  102. #define    S_ISSOCK(m)    (((m)&S_IFMT) == S_IFSOCK)    /* socket */
  103. #endif
  104.  
  105. /*
  106.  * POSIX 1003.1 5.6.1.2 <sys/stat.h> File Modes
  107.  */
  108.  
  109. #if !defined (S_IRWXU)
  110. #  if !defined (S_IREAD)
  111. #    define S_IREAD    00400
  112. #    define S_IWRITE    00200
  113. #    define S_IEXEC    00100
  114. #  endif /* S_IREAD */
  115. #
  116. #  if !defined (S_IRUSR)
  117. #    define S_IRUSR    S_IREAD            /* read, owner */
  118. #    define S_IWUSR    S_IWRITE        /* write, owner */
  119. #    define S_IXUSR    S_IEXEC            /* execute, owner */
  120. #
  121. #    define S_IRGRP    (S_IREAD  >> 3)        /* read, group */
  122. #    define S_IWGRP    (S_IWRITE >> 3)        /* write, group */
  123. #    define S_IXGRP    (S_IEXEC  >> 3)        /* execute, group */
  124. #
  125. #    define S_IROTH    (S_IREAD  >> 6)        /* read, other */
  126. #    define S_IWOTH    (S_IWRITE >> 6)        /* write, other */
  127. #    define S_IXOTH    (S_IEXEC  >> 6)        /* execute, other */
  128. #  endif
  129. #
  130. #  define S_IRWXU    (S_IRUSR | S_IWUSR | S_IXUSR)
  131. #  define S_IRWXG    (S_IRGRP | S_IWGRP | S_IXGRP)
  132. #  define S_IRWXO    (S_IROTH | S_IWOTH | S_IXOTH)
  133. #endif /* !S_IRWXU */
  134.  
  135. /* These are non-standard, but are used in builtins.c$symbolic_umask() */
  136. #define S_IRUGO        (S_IRUSR | S_IRGRP | S_IROTH)
  137. #define S_IWUGO        (S_IWUSR | S_IWGRP | S_IWOTH)
  138. #define S_IXUGO        (S_IXUSR | S_IXGRP | S_IXOTH)
  139.  
  140. #endif /* _POSIXSTAT_H */
  141.